/********************************************************************************
*                 Copyright (C) 2011 - Las Venturas Playground                  *
*                      http://iv-mp.nl | http://lvp-iv.com                      *
*                                                                               *
*    This program is free software: you can redistribute it and/or modify       *
*    it under the terms of the GNU General Public License as published by       *
*    the Free Software Foundation, either version 3 of the License, or          *
*    (at your option) any later version.                                        *
*                                                                               *
*    This program is distributed in the hope that it will be useful,            *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of             *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
*    GNU General Public License for more details.                               *
*                                                                               *
*    You should have received a copy of the GNU General Public License          *
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
*                                                                               *
*********************************************************************************
*                                                                               *
*  Las Venturas Playground - Commands/managementCommands.nut                    *
*                                                                               *
*  This file will hold all management commands.                                 *
*                                                                               *
********************************************************************************/

local cmdHandler = CommandHandler ();

/**
 * This is the /move command, the command moves the player in x y z direction.
 * @author: Sander <sander@sa-mp.nl>
 *
 * @param playerid The playerid that used the command.
 * @param commandParams The parameters passed on to the command.
 * @param commandText The entire command as a string.
 */
local function cmdMove (playerid, commandParams, commandText) 
{
    if (commandParams.len () < 4)
    {
        sendPlayerUsageMessage (playerid, "/move x, y, z");
        return;
    }
    
    // Get the x y z values the player wants to move
    local move_x = commandParams[1].tointeger ();
    local move_y = commandParams[2].tointeger ();
    local move_z = commandParams[3].tointeger ();
    
    // Get current player position
    local aPlayerPos = getPlayerCoordinates (playerid);
    
    // Set the new position
    setPlayerCoordinates (playerid, (aPlayerPos[0] + move_x), (aPlayerPos[1] + move_y) , (aPlayerPos[2] + move_z) );
    setCameraBehindPlayer (playerid);

}
cmdHandler.registerCommand ("/move", Command (cmdMove), COMMAND_LEVEL_MANAGEMENT);

/**
 * This is the /restartgm command, it reloads the script by sending the reloadscript command to the console.
 * @author: Matthias <matthias@sa-mp.nl>
 *
 * @param playerid The playerid that used the command.
 * @param commandParams The parameters passed on to the command. No parameters are required by this command.
 * @param commandText The entire command as a string. No parameters are required by this command.
 */
local function cmdRestartGamemode (playerid, commandParams, commandText) 
{
    log (format ("The gamemode was restarted by " + getPlayerName (playerid)));
    sendPlayerMessage (playerid, "Restarting gamemode...", 0xFFFFFFFF, true);
	
	sendConsoleInput ("reloadscript lvp.nut");
}
cmdHandler.registerCommand ("/restartgm", Command (cmdRestartGamemode), COMMAND_LEVEL_MANAGEMENT);
